What causes stack smashing in C and how can I fix it in my program